<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Monitor extends MY_Controller {
    
    public function __construct()
    {
        parent::__construct();  
        $this->load->model('monitor_mod');
    }
      
    /**
     *   
     *    
     */
    public function index( )
    {        
        $data['menu_page'] = "monitor"; // Koja je stranica. current menu item
        //$data['messages']= $this->monitor_mod->getMessages();
        // Definisi koji se view ucitava
        $data['messages']= $this->monitor_mod->getMessages();
        $data['contents'] = 'monitor/monitor_home';
        $this->load->view('main',$data);
    }
    public function filter_submit() {
        try {
            $filter = $this->input->post('filter');
            $data['messages'] = $this->monitor_mod->getFilteredMessages($filter);
            $html = $this->load->view('monitor/monitor_list', $data, true);
            $response = array(
                'ind' => 1,
                'msg' => "",
                'num_users' => 0,
                'html' => $html
            );
        } catch (Exception $e) {

            $response = array(
                'ind' => 0,
                'msg' => 'Following errors occured: <br />' . $e->getMessage(),
                'num_users' => 0,
                'html' => ''
            );
        }
        echo json_encode($response);
    }
}
?>